package cn.tedu._05interceptor.base.config;

import cn.tedu._05interceptor.base.interceptors.MyInterceptor1;
import cn.tedu._05interceptor.base.interceptors.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {//标准化配置接口
    //快捷键addI
    @Override//重写拦截器中添加拦截器的方法
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器并添加拦截策略
        //registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/user/reg");
        //拦截器注册
        //registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/**");//两个*代表所有
        //registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/user/reg","/v1/user/login");//拦截多个请求，拦截登录和注册
//        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/user/**");//拦截用户模块的所有请求
//        //拦截用户模块中的有功能，除了注册之外的所有请求
//        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/user/**").excludePathPatterns("/v1/user/reg");
//        registry.addInterceptor(new MyInterceptor1()).addPathPatterns("/v1/**");
//        registry.addInterceptor(new MyInterceptor2()).addPathPatterns("/v1/**");
    }
}
